﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIEffect : UIDialog 
{
	private Sprite effectImg; 
	private float? w = null;
	private float? h = null;
	public bool isLeaf = false;	//是否是树丛特效
	public bool isSeed = false; //是否种子
	public bool isRoot = false; //是否是根

	void Start () 
	{
		this.getRectTransform ().sizeDelta = new Vector2 (effectImg.rect.x, effectImg.rect.y);
		Image img = gameObject.GetComponent<Image> ();
		img.sprite = effectImg;

		if (w != null && h != null) 
		{
			getRectTransform().sizeDelta = new Vector2 ((float)w, (float)h);
		}

	}

	public void addEffect(string effectPath)
	{
		isLeaf = (effectPath == "leaf");
		isRoot = (effectPath == "shitIcon");
		effectImg = Resources.Load(effectPath, typeof(Sprite)) as Sprite;
	}
	
	void Update () 
	{
		
	}

	public void setSize(float w, float h)
	{
//		if (this.getRectTransform ())
//			this.getRectTransform ().sizeDelta = new Vector2 (w, h);
//		else 
//		{
			this.w = w;
			this.h = h;
//		}
	}

	public override string path ()
	{
		return "UIDialog/UIEffect";
	}
}
